﻿using System;
using System.Collections.Generic;

namespace BaseSyntax.Boxing
{
	public class StructBoxing:ITest
	{
		struct ST
		{
			public int a;
		}


		public void Test()
		{
			ST st1 = new ST();
			st1.a = 2;
			
			List<ST> sts = new List<ST>();
			sts.Add(st1);

			// 封箱成object类型
			object oj = sts[0];
			
			ST st3 = (ST) oj;
			st3.a = 3;
			// xxx yyy xxx
			Console.WriteLine($"{oj.GetHashCode()},{st3.GetHashCode()}, {sts[0].GetHashCode()}");
			
			
			//3 2 结构体是值类型，每个结构体都是做的复制
			Console.WriteLine($"{st3.a}, {sts[0].a}");
			
		}
	}
}